# 循环播放背景图
# NASA 2021-10-4
import pygame
import sys


def bg():
    pygame.init()
    winx = 800
    winy = 199
    screen = pygame.display.set_mode((winx, winy))
    fclock = pygame.time.Clock()
    bg_img = pygame.image.load('..\\pictures\\bg.png')
    x1 = 0
    x2 = winx
    y = 0
    while True:
        for e in pygame.event.get():
            if e.type == pygame.QUIT:
                pygame.quit()
                sys.exit()

        x1 -= 5
        x2 -= 5
        if x1 < -796:
            x1 = winx
        if x2 < -796:
            x2 = winx
        screen.blit(bg_img, (x1, y))
        screen.blit(bg_img, (x2, y))
        pygame.display.update()
        screen.fill((0, 0, 0))
        fclock.tick(25)


if __name__ == '__main__':
    bg()  # background
